<!-- 蓝色简洁登录页面 -->
<template>
	<view class="login-bg">
		
		
		<image class="img-a" src="@/static/img/bg1.png"></image>
	
		<view class="t-login">
			<view class="t-b">登 录</view>
			<form class="cl">
				<view class="t-a">
					<image src="@/static/img/user.png"></image>
					<input type="number" name="password" placeholder="请输入手机号码" maxlength="11" v-model="email" />
				</view>
				<view class="t-a">
					<image src="@/static/img/pwd.png"></image>
					<input type="password" name="password" maxlength="6" placeholder="请输入密码" v-model="password" />
				</view>
				<view class="t-c" @tap="forgotPwd()">忘记密码</view>
				<button @tap="login()">登 录</button>
			</form>
		</view>
		<view class="cardBox">
			<view>
				还没有登录账号？
				<text class="txt" @tap="reg()">立刻注册</text>
			</view>
		</view>
		<image class="img-b" src="@/static/img/bg2.png"></image>
	</view>
</template>
<script>
export default {
	
	data() {
		return {
			email: '', //手机号码
			password: '' //密码
		};
	},
	onLoad() {},
	methods: {
		//当前登录按钮操作
		login() {
			let that = this
			uni.showLoading({
				mask: true,
				title: "加载中..."
			})
			let opts = {
				// url: 'smsLogin',
				url: 'login',
				method: 'POST'
			};
			let param = {
				// phone: this.email,
				// smsCode: this.password
				userName: this.email,
				password: this.password,
				loginType: 'APP'
			};
			this.$http.httpRequest(opts, param).then(res => {
				console.log(res.data)
				if (res.data.code == 200) {
					uni.setStorageSync('token', res.data.data);
					uni.hideLoading();
					uni.showToast({
						title: '登陆成功',
						icon: 'success',
						duration: 1500
					});
					console.log('登录成功！')
					let opts = {
						url: 'getLoginUser',
						method: 'GET'
					};
					this.$http.httpTokenRequest(opts).then(res => {
						uni.setStorageSync('userInfo', res.data.data.user); //用户信息
						setTimeout(() => {
							/* uni.reLaunch({
								url: '/pages/control-tower/control-tower'
							}); */
							uni.reLaunch({
								url: '/pages/home/index'
							});
						}, 2000);
						
						console.log("############" + '登录成功！')
						// this.wxAuth();
						// if(res.data.data.user.userType == 'admin' || res.data.data.user.userType == 'pick'){
			
						// }
						// else{
			
						// }
					})
			
			
				} else {
					uni.hideLoading();
					this.messageToggle('error', res.data.msg)
					return;
				}
			})
		},
		//忘记密码
		forgotPwd() {
			uni.showToast({ title: '忘记密码', icon: 'none' });
		},
		//立刻注册
		reg() {
			uni.showToast({ title: '立刻注册', icon: 'none' });
		}
	}
};
</script>
<style>
.img-a {
	width: 100%;
}
.img-b {
	width: 100%;
	height: 45px;
	bottom: 0;
	position: absolute;
}
.login-bg {
	height: 100vh;
	background: linear-gradient(to bottom, #2796f2, #2796f2);
}

.t-login {
	width: 580rpx;
	padding: 55rpx;
	margin: 0 auto;
	font-size: 28rpx;
	background-color: #ffffff;
	border-radius: 20rpx;
	position: relative;
	margin-top: -200rpx;
	box-shadow: 0 5px 7px 0 rgba(0, 0, 0, 0.15);
	z-index: 9;
}
.t-login button {
	font-size: 28rpx;
	background: linear-gradient(to right, #2796f2, #2796f2);
	color: #fff;
	height: 90rpx;
	line-height: 90rpx;
	border-radius: 50rpx;
}

.t-login input {
	padding: 0 20rpx 0 120rpx;
	height: 90rpx;
	line-height: 90rpx;
	margin-bottom: 50rpx;
	background: #f6f6f6;
	border: 1px solid #f6f6f6;
	font-size: 28rpx;
	border-radius: 50rpx;
}

.t-login .t-a {
	position: relative;
}

.t-login .t-a image {
	width: 40rpx;
	height: 40rpx;
	position: absolute;
	left: 40rpx;
	top: 28rpx;
	padding-right: 20rpx;
}

.t-login .t-b {
	text-align: left;
	font-size: 46rpx;
	color: #2796f2;
	font-weight: bold;
	margin: 0 0 50rpx 20rpx;
}

.t-login .t-d {
	text-align: center;
	color: #999;
	margin: 80rpx 0;
}

.t-login .t-c {
	text-align: right;
	color: #c0c0c0;
	margin: -20rpx 30rpx 40rpx 0;
}

.t-login .t-f {
	text-align: center;
	margin: 200rpx 0 0 0;
	color: #666;
}

.t-login .t-f text {
	margin-left: 20rpx;
	color: #aaaaaa;
	font-size: 27rpx;
}

.t-login .uni-input-placeholder {
	color: #aeaeae;
}

.cl {
	zoom: 1;
}

.cl:after {
	clear: both;
	display: block;
	visibility: hidden;
	height: 0;
	content: '\20';
}
.cardBox {
	-webkit-box-orient: horizontal;
	-webkit-box-direction: normal;
	-webkit-flex-direction: row;
	flex-direction: row;
	-webkit-box-align: center;
	-webkit-align-items: center;
	align-items: center;
	padding: 5px;
	background: #ffffff;
	opacity: 0.9;
	-webkit-border-radius: 20rpx;
	border-radius: 0 0 20rpx 20rpx;
	height: 70rpx;
	width: 600rpx;
	margin: 0 auto;
	position: relative;
	text-align: center;
	line-height: 70rpx;
	color: #aaa;
	font-size: 28rpx;
}
.cardBox .txt {
	color: #fe519f;
}
</style>
